package com.ruoyi.web.controller.storage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.storage.bicycle.domain.Bicycle;
import com.ruoyi.storage.bicycle.domain.vo.BicycleFittingVo;
import com.ruoyi.storage.bicycle.domain.vo.BicycleVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.storage.orderWarehousing.domain.BicycleOrder;
import com.ruoyi.storage.orderWarehousing.service.IBicycleOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他入库单Controller
 * 
 * @author zzx
 * @date 2024-02-06
 */
@RestController
@RequestMapping("/orderwarehousing/orderwarehousing")
public class BicycleOrderController extends BaseController
{
    @Autowired
    private IBicycleOrderService bicycleOrderService;

    /**
     * 查询其他入库单列表
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bicycle bicycle)
    {
        startPage();
        List<Bicycle> list = bicycleOrderService.selectBicycleOrderList(bicycle);
        return getDataTable(list);
    }

    /**
     * 导出其他入库单列表
     */
//    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:export')")
//    @Log(title = "其他入库单", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BicycleOrder bicycleOrder)
//    {
////        List<BicycleOrder> list = bicycleOrderService.selectBicycleOrderList(bicycleOrder);
////        ExcelUtil<BicycleOrder> util = new ExcelUtil<BicycleOrder>(BicycleOrder.class);
////        util.exportExcel(response, list, "其他入库单数据");
//    }

    /**
     * 获取其他入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:query')")
    @GetMapping(value = "/{bicycleId}")
    public AjaxResult getInfo(@PathVariable("bicycleId") String bicycleId)
    {
        return success(bicycleOrderService.selectBicycleOrderByBicycleId(bicycleId));
    }

    /**
     * 新增其他入库单
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:add')")
    @Log(title = "其他入库单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BicycleVo bicycle)
    {
        return bicycleOrderService.insertBicycleOrder(bicycle);
    }

    /**
     * 修改其他入库单
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:edit')")
    @Log(title = "其他入库单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BicycleVo bicycle)
    {
        return bicycleOrderService.updateBicycleOrder(bicycle);
    }

    /**
     * 删除其他入库单
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:remove')")
    @Log(title = "其他入库单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bicycleIds}")
    public AjaxResult remove(@PathVariable String[] bicycleIds)
    {
        return toAjax(bicycleOrderService.deleteBicycleOrderByBicycleIds(bicycleIds));
    }
    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:edit')")
    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PutMapping("/updateAudit/{bicycleIds}")
    public AjaxResult updateAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleOrderService.updateAudit(bicycleIds);
    }
    /**
     * 反审核
     */
    @PreAuthorize("@ss.hasPermi('orderwarehousing:orderwarehousing:edit')")
    @Log(title = "反审核", businessType = BusinessType.UPDATE)
    @PutMapping("/updateUnAudit/{bicycleIds}")
    public AjaxResult updateUnAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleOrderService.updateUnAudit(bicycleIds);
    }
}
